home *** CD-ROM | disk | FTP | other *** search
- Path: lrz-muenchen.de!news
- From: watzka@stat.uni-muenchen.de (Kurt Watzka)
- Newsgroups: comp.lang.c
- Subject: Re: passing arrays and returning structs
- Date: 12 Mar 1996 08:35:43 GMT
- Organization: Leibniz-Rechenzentrum, Muenchen (Germany)
- Distribution: world
- Message-ID: <4i3d0v$96p@sparcserver.lrz-muenchen.de>
- References: <4i2128$69d@news2.acs.oakland.edu> <4i27eo$202@newsgate.dircon.co.uk>
- NNTP-Posting-Host: sun2.lrz-muenchen.de
-
- sridgway@dircon.co.uk (Steven Ridgway) writes:
-
- >jggoslin@vela.acs.oakland.edu (Monument) wrote:
-
- >>struct Message transitive_closure(int matrix[]);
-
- [and later in the same source file]
-
- >>struct Message* transitive_closure(int matrix[])
- >>{
-
- [Implementation of transitive closure edited]
-
- >>}
- >>===client.c===
-
- >>===ERRORS===
- >>/usr/lib/cmplrs/cc/cfe: Error: client.c, line 73: redeclaration of 'transitive_closure'; previous declaration at line 11 in file 'client.c'
- >> struct Message* transitive_closure(int matrix[])
- [other error messages edited]
- >>Stop.
- >>===ERRORS===
-
- >Hi,
-
- >You have at least three problems here.
-
- >1. You should prototype your function transitive_closure before
- >you use it. ie add the line :
- >struct Message* transitive_closure(int matrix[]);
-
- How would you interpret the line
-
- struct Message transitive_closure(int matrix[]);
-
- It looks like a function prototype to me, but it does not match the
- function definition. And _that_ is at least part of the real problem.
-
- >at the top of your file or in a header (before you reference it but
- >after you define Message anyway).
-
- >Without this the compiler assumes it returns int, then whines when you
- >define it as something else.
-
- The compiler clearly reports that there _is_ a previous declaration
- for the function in line 11. This implies that there has been a
- previous declaration, doesn't it?
-
- [correct analysis of a problem with returning a pointer to a local
- variable with automatic storage edited]
-
- Kurt
- --
- | Kurt Watzka Phone : +49-89-2180-6254
- | watzka@stat.uni-muenchen.de
- | ua302aa@sunmail.lrz-muenchen.de
-